home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / inifil / inifile.txt < prev   
Text File  |  1994-10-06  |  2KB  |  58 lines

  1. This module contains routine(s) that can assist in dealing with INI files for an application.
  2. Since INI files are suppose to be placed in the Windows directory, I wrote these routines to 
  3. check and see if it exists in the users directory, if it doesn't then I copy a 
  4. default INI from the application directory. 
  5.  
  6. Typical Calling:
  7.  
  8. Global Declarations
  9.  
  10. Global Dim gsMsg as String
  11. Global Dim gsMsgTitle as String
  12. Global Const gnSuccess = 0
  13.  
  14. Module Declarations
  15.  
  16.     Dim sProfileName as String
  17.     Dim nReturnStaus as Integer
  18. '
  19. '   Build the INI file name
  20. '
  21.     sProfileName = GetWinDir() & App.EXEName & ".INI"
  22. '
  23. '   Check to see if the INI file is in the users
  24. '   Windows directory. If it is not, then move a
  25. '   default copy there.
  26. '
  27.     If FileExists(sProfileName) = False Then
  28.         nReturnStatus = CopyFile(App.Path & "\" & App.EXEName & ".INI", sProfileName)
  29.         If nReturnStatus <> gnSuccess Then
  30.             MsgBox gsMsg, MB_ICONSTOP, gsMsgTitle
  31.             End
  32.         End If
  33.     End If
  34.  
  35. The following routines exists.
  36.  
  37.     GetWinDir()    
  38.         This routine will return a string indicating the users Windows directory
  39.  
  40.     GetWinSysDir()    
  41.         This routine will return a string indicating the users Windows System directory
  42.  
  43.     FileExists(Filename)    
  44.         This routine will check to see if a file exists.
  45.         This routine accepts a string containing the file name (and optional path)
  46.         This routine will return TRUE if the file exists, False otherwise.
  47.  
  48.     CopyFile(Source, Destination)    
  49.         This routine will copy a file from one location to another.
  50.         This routine accepts two strings, source and destination, and accepts no wildcards
  51.         This routine will return the error number if an error occurrs, or 0.
  52.         It will also return a message in the gsMsg and gsMsgTitle strings.
  53.  
  54. If you have any questions/suggestions, please feel free to drop my an E-Mail
  55.  
  56. Chad Hegerty
  57. 71212,1045
  58.